from django.db import models

# Create your models here.



# python manage.py makemigrations  # 生成迁移文件
# python manage.py migrate  # 执行迁移命令


class Student(models.Model):
    name = models.CharField('姓名',max_length=20)
    age = models.SmallIntegerField('年龄',null=True)
    sex = models.SmallIntegerField('性别',default=1)
    qq = models.CharField('QQ',max_length=20, unique=True)
    phone = models.CharField('电话',max_length=11,unique=True)
    c_time = models.DateTimeField('创建时间',auto_now_add=True)
    image_url = models.URLField(default='',verbose_name='图片URL')
    g = models.ForeignKey('Grade',on_delete=models.SET_NULL, null=True)
    is_delete = models.BooleanField(default=False,verbose_name='逻辑删除')

    class Meta:
        db_table = 'student'
        verbose_name = '学生'

    def __str__(self):
        return '{}-{}'.format(self.name, self.age)

class Grade(models.Model):
    name = models.CharField(max_length=64, verbose_name='班期名字')

    class Meta:
        db_table = 'tb_grade'
        verbose_name = '班期'
    def __str__(self):
        return self.name
